<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
use yii\widgets\DetailView;
use yii\widgets\Pjax;
use dmstr\bootstrap\Tabs;

/**
 * @var yii\web\View $this
 * @var yiike\store\models\Goods $model
 */
$copyParams = $model->attributes;

$this->title = Yii::t('models', 'Goods');
$this->params['breadcrumbs'][] = ['label' => Yii::t('models', 'Goods'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => (string)$model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'View';
?>
<!-- flash message -->
<?php if (\Yii::$app->session->getFlash('deleteError') !== null) : ?>
    <span class="alert alert-info alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span></button>
        <?= \Yii::$app->session->getFlash('deleteError') ?>
        </span>
<?php endif; ?>
<div class="box box-info giiant-crud goods-view">
    <div class="box-header with-border">
        <div class="box-title">
            <?= $model->title ?>        </div>
    </div>

    <div class="box-body">

        <?php $this->beginBlock('yiike\store\models\Goods'); ?>


        <?= DetailView::widget([
            'model' => $model,
            'attributes' => [
                'title',
                'sub_title',
                'goods_sn',
                'cost_price',
                'sold',
                'stock',
                [
                    'attribute' => 'status',
                    'value' => function ($model) {
                        return $model->statusText;
                    }
                ],
                [
                    'attribute' => 'logo',
                    'format' => 'html',
                    'value' => function ($model) {
                        $html = '';
                        $images = explode(',', $model->image);
                        foreach ($images as $img) {
                            $html .= Html::img($img, ['width' => 80]);
                        }
                        return $html;
                    }
                ],
            ],
        ]); ?>


        <hr/>

        <?php $this->endBlock(); ?>

        <?php $this->beginBlock('goods_content'); ?>
            <?=Html::decode($model->content) ?>
        <?php $this->endBlock(); ?>
        <?= Tabs::widget(
            [
                'id' => 'relation-tabs',
                'encodeLabels' => false,
                'items' => [
                    [
                        'label'   => '<b class="">商品信息</b>',
                        'content' => $this->blocks['yiike\store\models\Goods'],
                        'active'  => true,
                    ],
                    [
                        'label'   => '<b class="">描述详情</b>',
                        'content' => $this->blocks['goods_content'],
                        'active'  => false,
                    ],
                ]
            ]
        );
        ?>    </div>
</div>
